/**
* Represents a CheckBox Asset
* @author Default
* @version 0.1
*/
import com.thelab.ui.*;

class com.thelab.ui.CheckBox extends UIElement
{

	
	private var __state:Boolean;	
	
	public function CheckBox(scope:MovieClip,px:Number,py:Number,size:Number,checked:Boolean)
	{
		super("UICheckBox",scope);		
		target._x = px || 0;
		target._y = py || 0;		
		style.size = size || 5;
		__state = checked = checked || false;
		onDoubleClick = undefined;
		draw();
	}	
	
	function set _state(b:Boolean)
	{ 
		__state = b;
		draw();
	}
	function get _state():Boolean { return __state; }
	
	private function update_style()
	{		
		draw();
	}
	
	private function onClick(ref:CheckBox)
	{
		ref._state = !ref._state;
		ref.onCheck(ref,_state);
	}
	
	function draw()
	{		
		var s:Number = style.size;
		var temp:UIStyle = style;
		target.clear();
		
		target.lineStyle(); target.beginFill(0,0); square(0,0);	target.endFill();
		
		target.lineStyle(style.linethick,style.linecolor,style.linealpha);
		square(0,0);
		if(__state)
		{
			style.size = s*0.5;
			target.lineStyle();
			target.beginFill(style.checkcolor,style.backalpha);
			square(0,0);
			target.endFill();
		}
		style.size = s;
	}
	
	
	
	
}